package com.devunion.bogdan.view.project.dialogs;

import org.apache.commons.io.FilenameUtils;

/**
 * @author Viktar Liaskovich
 */
public abstract class FileNameTransformer {
    public static FileNameTransformer pyTransformer = createPyTransformer();

    public abstract String transform(String filename);

    private static FileNameTransformer createPyTransformer() {

        return new FileNameTransformer() {
            public String transform(String filename) {
                if (!"py".equalsIgnoreCase(FilenameUtils.getExtension(filename))) {
                    if (filename.endsWith(".")) {
                        return filename + "py";
                    }

                    return filename + ".py";
                }

                return filename;
            }
        };
    }
}
